//------------------------------------------------------------------------------
// X2TK Graphic Toolkit
// Copyright (C) 2006-2008 Janusz Kowalski
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------

#include "RawVector.h"
#include "x2tk_Widget.h"

#ifndef X2TK_CONTAINER_H
#define X2TK_CONTAINER_H

// Container is a kind of widget that can contain other widgets.

namespace x2tk {

class Container : public Widget {
  private:
    Widget *parent;
    bool manageFocus_;
    bool emergeFocus_;
    
    Widget *giveFocus(Widget *child);
    
    bool keepFocus_;
  public:
    Container(int x, int y, int w, int h);
    // Destroys container and all it's children
    ~Container();

    virtual void draw(GraphicContext &g);
    
    bool mouseDown(int type);
    void mouseUp(int type);
    void mouseMove(int x, int y);
    
    // child=x, v=true - Give focus to child x.
    // child=x, v=false - Give focus to some other child than x.
    
    void setManageFocus(bool v) {manageFocus_=v;}
    // Move widgets with focus to the top.
    void setEmergeFocus(bool v) {emergeFocus_=v;}
    
    void setKeepFocus(bool v) {keepFocus_=v;}
    
    virtual void resize(int w, int h);};

} // namespace x2tk

#endif
